<!DOCTYPE html>
<html lang="zh" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('片库列表')"/>
    <th:block th:include="include :: layout-latest-css"/>

</head>
<body class="gray-bg">
<div class="ui-layout-west">
    <div class="box box-main">
        <div class="box-header">
        </div>
        <div class="ui-layout-content">
            <div class="ztree" id="tree"></div>
        </div>
    </div>
</div>

<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="user-form">
                    <input id="categoryId" name="categoryId" type="hidden">
                    <input id="parentId" name="parentId" type="hidden">

                    <div class="select-list">
                        <ul>
                            <li>
                                资源名称：<input name="name" type="text"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                        class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                        class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="system:shipin:add">
                    <i class="fa fa-plus"></i> 新增
                </a>
                <button class="btn btn-primary" id="button-open-9" type="button">一键发布价格</button>
                <a class="btn btn-danger multiple disabled" onclick="javascript:batchForceLogout()">
                    <i class="fa fa-sign-out"></i> 修改价格
                </a>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table data-mobile-responsive="true" id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</div>


<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:shipin:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:shipin:remove')}]];
    var prefix = ctx + "system/shipin";
    console.log(ctx);
    $(function () {
        queryUserList();

    });

    function queryUserList() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            sortName: "createTime",
            sortOrder: "desc",
            modalName: "视频",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'id'
                },
                {
                    field: 'name',
                    title: '资源名称'
                },

                {
                    field: 'money',
                    title: '公共价格/单位(元)',
                    sortable: true
                },

                {
                    field: 'privateMoney',
                    title: '私人价格/单位(元)',
                },

                {
                    field: 'cs',
                    title: '打赏人数',
                },
                {
                    field: 'url',
                    title: '图片链接',
                    sortable: true,
                    formatter: function (value, row, index) {
                           return $.table.imageView(row.logo);
                    }
                },


<!--                {-->
<!--                    field: 'videoUrl',-->
<!--                    title: '视频链接'-->
<!--                },-->

                {
                    visible: editFlag === 'hidden',
                    title: '用户状态',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return statusTools(row);
                    }
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    sortable: true
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    }


    $('#btnExpand').click(function () {
        $._tree.expandAll(true);
        $(this).hide();
        $('#btnCollapse').show();
    });

    $('#btnCollapse').click(function () {
        $._tree.expandAll(false);
        $(this).hide();
        $('#btnExpand').show();
    });


      $("#button-open-9").click(function () {
            layer.prompt({title: '请输入视频价格，并确认', formType: 0}, function (price, index) {
                 $.modal.loading("保存中...");
                    $.ajax({
                        type: "post",
                        url:  "/system/shipin/price",
                        data: {
                            "price": price
                        },
                        success: function (r) {
                            if (r.code === 0) {
                                 $.modal.closeLoading();
                                 layer.close(index);
                                 $.table.refresh();
                            } else {
                                $.modal.closeLoading();
                                $.modal.msg(r.msg);
                                layer.close(index);
                            }
                        }
                    });

            });
        });



    // 单条强退
    function forceLogout(id) {
        $.modal.confirm("确定要强制选中用户下线吗？", function () {
            var data = {"id": id};
            $.operate.post(prefix + "/forceLogout", data);
        })
    }

    // 批量强退
    function batchForceLogout() {
        var rows = $.table.selectColumns("id");
        if (rows.length == 0) {
            $.modal.alertWarning("请选择要修改的片库数据");
            return;
        }
      layer.prompt({title: '请输入视频价格，并确认', formType: 0}, function (price, index) {
                 $.modal.loading("保存中...");
                    $.ajax({
                        type: "post",
                        url:  "/system/shipin/batchForceLogout",
                        data: {
                            "price": price,
                            "ids": rows
                        },
                        success: function (r) {
                            if (r.code === 0) {
                                 $.modal.closeLoading();
                                 layer.close(index);
                                 $.table.refresh();
                            } else {
                                $.modal.closeLoading();
                                $.modal.msg(r.msg);
                                layer.close(index);
                            }
                        }
                    });

            });
    }






</script>
</body>

</html>